<?php

namespace Lib\WS;

class WS {

	public function __call($sName, $aParam) {
		try {
			if (! extension_loaded ( 'soap' )) {
				new ExceptionExt ( '缺少SOAP扩展' );
			}
		} catch ( ExceptionExt $e ) {
			$e->showError ();
		}
		if (empty ( $aParam )) {
			return false;
		}
		if (! $this->$sType) {
		}
		if ($sName == 'Client' || $sName == 'Server') {
			$sName = '__construct';
		}
		return call_user_func_array ( array (
				$this->$sType,
				$sName 
		), $aParam );
	}

	public function __get($sName) {
		$sName = $sName == 'Server' ? 'Server' : 'Client';
		if (! $this->$sName) {
			require_once __DIR__ . '/' . $sName . '.class.php';
			$sClass = __NAMESPACE__ . '\\' . $sName;
			$this->__set ( $sName, new $sClass () );
		}
		return $this->$sName;
	}

	public function __set($sName, $sValue) {
		$this->$sName = $sValue;
	}
}

?>